import 'dart:ui';

import 'package:flutter/material.dart';
import 'package:maxhub/view/index_page.dart';
import 'package:mqtt_client/mqtt_server_client.dart';

class LightBeltPages extends StatefulWidget {
  @override
  State<StatefulWidget> createState() => _LightBeltPagesState();
}


class _LightBeltPagesState extends State<LightBeltPages> {
  @override
  Widget build(BuildContext context) {
    return Wrap(children: <Widget>[
      Stack(
        alignment: AlignmentDirectional.center,
        children: <Widget>[
          Container(
            alignment: Alignment.topLeft,
            child: Image.asset('images/灯带_0001.png',
                width: MediaQuery.of(context).size.width / 1.3,
                height: MediaQuery.of(context).size.height / 8),
          ),
          Container(
            alignment: Alignment(-0.5, 0.0),
            child: Text('LED灯带',
                style: TextStyle(color: Colors.white, fontSize: 18)),
          ),
        ],
      ),
      Container(
          width: MediaQuery.of(context).size.width,
          height: (MediaQuery.of(context).size.height / 9.45) * 7,
          child: GridView.count(
            shrinkWrap: true,
            crossAxisCount: 2,
            mainAxisSpacing: 10,
            crossAxisSpacing: 10,
            childAspectRatio: 1.8,
            children: [
            ],
          )),
    ]);
  }

}

final MediaQueryData mediaQuery = MediaQueryData.fromWindow(window);



//查询过来的十六进制转换为颜色
String SixtoColor(data) {
  var color = '';
  List<String> strs = data.split(' ');
  for (int i = 0; i <= 3; i++) {
    if (color.length == 0) {
      color = strs[i].substring(2);
    } else {
      if (i == 3) {
        color =
            (strs[i].substring(2).length == 1 ? '00' : strs[i].substring(2)) +
                color;
      } else {
        color = color +
            (strs[i].substring(2).length == 1 ? '00' : strs[i].substring(2));
      }
    }
  }
  return '0x' + color;
}

//将颜色转换为十六进制颜色
String ColortoSix(data) {
  var x = '0x';
  var color = data.toString().substring(2);
  var one = color.substring(0, 2);
  var two = color.substring(2, 4);
  var three = color.substring(4, 6);
  var four = color.substring(6, 8);
  return x + two + ' ' + x + three + ' ' + x + four + ' ' + x + one;
}